package cn.stu.cms.service.impl;

import cn.stu.cms.util.MinioTool;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import static cn.stu.cms.common.CommonConstants.PATH_SEPERATOR;

/**
 * 异步法
 *
 * @author gh
 * @date 2023/10/23
 */

@Log4j2
@Component
@AllArgsConstructor
public class AsyncMethod {

    private MinioTool minioTool;


    /**
     * 删除图像
     *
     * @param objName OBJ名称
     */
    @Async("asyncExecutor")
    public void removeImage(Long userId, String objName) {
        Boolean isRemove = minioTool.removeBucketObject(minioTool.avatarBucketName, PATH_SEPERATOR + userId + PATH_SEPERATOR + objName);
        log.info("异步头像删除,{}", isRemove);
    }
}
